import java.io.File;
import java.io.FileReader;
import java.io.IOException;
import java.io.PrintWriter;
import java.util.NoSuchElementException;
import java.util.Scanner;


public class Main {
	public static void main(String[] args) throws IOException {
		Scanner reader = new Scanner(new FileReader("D:/input.txt"));
		PrintWriter writer = new PrintWriter(new File("D:/output.txt"));
		CustomHashMap1 map1 = new CustomHashMap1(14);
		CustomHashMap2 map2 = new CustomHashMap2(14);
		String specials = ".,:;!?)(";
		
		while(true) {
			try {
				String next = reader.next();
				next = next.toLowerCase();
				for (int i=0; i<specials.length(); i++) {
					if (next.charAt(next.length() - 1) == specials.charAt(i)) {
						next = next.substring(0, next.length() - 1);
						break;
					}
				}
				//if (next.charAt(0) == '(') {
				//	next = next.substring(1);
				//}
					

				if (map1.containsKey(next)) {
					map1.put(next, map1.get(next) + 1);
				} else {
					//System.out.print(j++ + " ");
					map1.put(next, 1);
				}
			
				if (map2.containsKey(next)) {
					map2.put(next, map2.get(next) + 1);
				} else {
					//System.out.print(j++ + " ");
					map2.put(next, 1);
				}



			} catch(NoSuchElementException e) {
				break;
			}
		}
		map1.print(writer);
		map2.print(writer);
	}
}
